#include"key.h"
void key_init(void)
{
    //中断包含gpio,AFIO,EXTI,NVIC
    //1.配置时钟
    RCC->APB2ENR|=RCC_APB2ENR_IOPFEN;
    RCC->APB2ENR|=RCC_APB2ENR_AFIOEN;

    //2.配置按键 PF10  CNF 10(上下拉输入)     MODE 00
    GPIOF->CRH &=~GPIO_CRH_MODE10;
    GPIOF->CRH |=GPIO_CRH_CNF10_1;
    GPIOF->CRH &=~GPIO_CRH_CNF10_0;
    GPIOF->ODR &=~GPIO_ODR_ODR10;

    GPIOF->CRH &=~GPIO_CRH_MODE8;
    GPIOF->CRH |=GPIO_CRH_CNF8_1;
    GPIOF->CRH &=~GPIO_CRH_CNF8_0;
    GPIOF->ODR |=GPIO_ODR_ODR8;

    //3.AFIO
    AFIO->EXTICR[2]&=~AFIO_EXTICR3_EXTI10;
    AFIO->EXTICR[2]&=~AFIO_EXTICR3_EXTI8;
    AFIO->EXTICR[2]|=AFIO_EXTICR3_EXTI10_PF;
    AFIO->EXTICR[2]|=AFIO_EXTICR3_EXTI8_PF;
    //4.EXTI
    EXTI->FTSR|=EXTI_FTSR_TR10;
    EXTI->IMR |=EXTI_IMR_MR10;
   EXTI->RTSR|=EXTI_RTSR_TR8;
    EXTI->IMR|=EXTI_IMR_MR8;

    //NVIC
    NVIC_SetPriorityGrouping(3);   //全部都是抢占优先级
    NVIC_SetPriority(EXTI15_10_IRQn,3);
    NVIC_EnableIRQ(EXTI15_10_IRQn);
    NVIC_SetPriority(EXTI9_5_IRQn,3);
    NVIC_EnableIRQ(EXTI9_5_IRQn);
}

//中断服务函数

